- Description of the replication files for "Trade Flows and Fiscal Multipliers”
- by Matteo Cacciatore and Nora Traum
- Review of Economics and Statistics
- Updated: October 7, 2020

- These codes call and use Dynare.  To reproduce the codes, one must first have Dynare installed.
- The results of the paper were run on Dynare Version 4.4.3 and Matlab 2016b. 



Figure 2 & Table 1 (prior-predictive analysis, section 3 of the paper):

Run the file run_priorpredictive.m in the “prior predictive analysis” folder.  This file takes draws from the priors and computes present value multipliers and probabilities of observing various multipliers (i.e., reproduces Table 1 and Figure 2).   Computation results are saved in the mat_files subfolder.

The script calls a series of functions that are contained within the same folder, most importantly:
-	get_prior_draw: This code takes draws from the priors for parameters
-	calibrate_bkk_for_estimation: Gives calibration for some parameters and calls steady-state solver codes
-	steadyBKK: sets up the steady-state of the model
-	steadyBKK_solver: function called by steadyBKK.m to solve for a specific set of steady state parameters.
-	newsteadyBKK: sets up the steady-state of a counterfactual model (i.e., closed economy)
-	newsteadyBKK_solver: function called by newsteadyBKK.m to solve for a specific set of steady state parameters.
-	display_results: displays results for Table 1 and makes Figure 2
-	BKKexp.mod: Dynare file with open-economy model
-	BKKexp_closed.mod: Dynare file with closed-economy model





Figure 3 (analysis using the estimated model, section 4 of the paper):

Run the file runme.m in the “estimation and posterior analysis”  folder.  This file will find the posterior mode, perform the Metropolis-Hastings algorithm, and save and report basic statistics about posterior draws. 
The script calls a series of functions that are contained within the same folder (several are referenced in the section above and for brevity are not repeated here), most importantly:
-	CanadaUSdata.xls: Contains all the data for the US and Canada; see the online appendix for more information about manipulations from original source files to final data format.  All manipulations are contained in the excel file.
-	get_data.m: loads data in final form for estimation.
-	priors.m: Calculates weight from priors
-	calculate_likelihood.m: Solves model and calculates the likelihood value using the Kalman filter
-	MHalogrithm.m: runs the Metropolis-Hastings algorithm for a given posterior mode
-	kalman_restrictedstate.m: Kalman filter code adapted from Dynare
-	run_posteriorpredictive.m: calculates open- and counterfactually closed-economy multipliers
-	display_results: displays results for Figure 3 



Figure 4 (model counterfactuals, section 4 of the paper):

Run the file run_posteriormean_counter.m in the “counterfactual posterior analysis”  folder to reproduce the counterfactual analysis at the posterior mean (i.e., to generate Figure 4 in the paper).  The script calls a series of functions that are contained within the same folder:
-	calibrate_bkk_for_estimation: Gives calibration for some parameters and calls steady-state solver codes
-	steadyBKK: sets up the steady-state of the model
-	steadyBKK_solver: function called by steadyBKK.m to solve for a specific set of steady state parameters.
-	newsteadyBKK: sets up the steady-state of a counterfactual model (i.e., closed economy)
-	newsteadyBKK_solver: function called by newsteadyBKK.m to solve for a specific set of steady state parameters.
-	Irfs: compute impulse response functions
-	BKKexp.mod: Dynare file with open-economy model
-	BKKexp_closed.mod: Dynare file with closed-economy model

